export default {
    type: 'form',
    name: 'user-role-assign-form',
    messages:{
        validateFailed:''
    },
    body:[
        {
            type: 'crud',
            api: {
                url: '/upms/admin/user/list/roleRelation',
                data:{
                    username: '${username}',
                    orgName: '${orgName}',
                    type: '${userType}',
                    roleId: '${id}',
                    page: '${page}',
                    perPage: '${perPage}',
                }
            },
            defaultParams:{
                roleId: '${id}'
            },
            //这里加data数据保存roleId（角色列表选中的id），一遍在批量按钮可以获取到，批量按钮使用${id}获取到的是第一行crud的id值
            data:{
                roleId: '${id}'
            },
            syncLocation: false,
            autoFillHeight: true,
            footerToolbar: [
                'statistics',
                'switch-per-page',
                'pagination'
            ],
            autoGenerateFilter: {
            showBtnToolbar: false,
                columnsNum: 4
            },
            bulkActions: [
                {
                label: '批量关联',
                actionType: 'ajax',
                level: 'primary',
                api: {
                    method: 'post',
                    url: '/upms/admin/role/assign/user',
                    data:{
                        userIds: '${SPLIT(ids)}',
                        roleId: '${roleId}'
                    }
                },
                },
                {
                    label: '批量取消关联',
                    level: 'danger',
                    actionType: 'ajax',
                    api: {
                        method: 'post',
                        url: '/upms/admin/role/revoke/user',
                        data:{
                            userIds: '${SPLIT(ids)}',
                            roleId: '${roleId}'
                        }
                    },
                }
            ],
            headerToolbar:[
                'bulkActions',
            ],
            columns: [
            {
                name: 'username',
                label: '用户名',
                searchable:{
                    type: 'input-text',
                    name: 'username',
                    label: '用户名',
                    clearable: true,
                    size: 'sm'
                },
            },
            {
                name: 'typeStr',
                label: '用户类型',
                searchable: {
                    type: 'select',
                    name: 'userType',
                    label: '用户类型',
                    source: '/base/dict/options/user-type',
                    clearable: true,
                    size: 'sm'
                },
            },
            {
                name: 'mainFlag',
                label: '主账号',
                type: 'mapping',
                map:{
                    "0": "<span class='text-danger'>否</span>",
                    "1": "<span class='text-success'>是</span>",
                }
            },
            {
                name: 'orgName',
                label: '所属机构',
                searchable: {
                    type: 'input-text',
                    name: 'orgName',
                    label: '所属机构',
                    clearable: true,
                    size: 'sm'
                }
            },
            {
                name: 'roleRelationFlag',
                label: '关联状态',
                type: 'mapping',
                map:{
                    '0':'<span class="text-danger">未关联</span>',
                    '1':'<span class="text-success">已关联</span>'
                }
            }]
        }
    ]
}